import QtQuick
import QtQuick.Controls

Window {
    id:snRoot
    width:Screen.width
    height:Screen.height
    title: "便签墙"
    flags: Qt.FramelessWindowHint
    visibility: Window.FullScreen
    color:"#00000000"
    Rectangle{
        width:parent.width
        height:parent.height
        color:"#00000000"
        border.width: 10
        border.color:"#00000000"
        Grid{
            x:10
            y:10
            columns:6
            spacing:5
            Repeater{
                model:localDB.readDataSN(root.userId)
                Rectangle{
                    property bool warn: modelData.timewarn===0
                    width:(snRoot.width-45)/6
                    height:256
                    color:"wheat"
                    TextEdit{
                        width:parent.width
                        readOnly: true  // 设置为只读，这样用户就不能编辑文本了
                        selectByMouse: true  // 允许通过鼠标选择文本
                        wrapMode: Text.Wrap
                        text:modelData.sncontent
                        padding: 10
                    }
                    Text{
                        x:parent.width-100
                        y:parent.height-80
                        text: warn ? qsTr("书写时间：\n"+Qt.formatDateTime(new Date(modelData.timewrite), "MM-dd HH:mm\n")):
                                     qsTr("书写时间：\n"+Qt.formatDateTime(new Date(modelData.timewrite), "MM-dd HH:mm\n")
                                          +"提醒时间：\n"+Qt.formatDateTime(new Date(modelData.timewarn), "MM-dd HH:mm"))
                    }
                    Text{
                        opacity:0.5
                        font.pixelSize:20
                        text:"X"
                        MouseArea{
                            anchors.fill: parent
                            onClicked:{
                                parent.parent.color="#00000000"
                                localDB.delStickyNote(root.userId,modelData.id)
                            }
                        }
                    }
                }
            }
        }
    }

    Button {
        text: "关闭"
        font.pixelSize:30
        opacity:0.3
        anchors.centerIn:parent
        onClicked: {
            snRoot.destroy()
            // 关闭当前窗口
        }
    }
}
